﻿<%@ Application Language="C#" %>
<%@ Import Namespace="System.Web.Routing" %>
<script runat="server">

    void Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup
        RegisterRoutes(RouteTable.Routes);
        //Code that runs on application startup
        //System.Timers.Timer myTimer = new System.Timers.Timer();
        //// Set the Interval to 5 seconds (500000 milliseconds).
        //myTimer.Interval = Convert.ToDouble(OsPortal.oStringHelper.fncGetAppSettings("SPACE_TIME_CHECK_UP_TIN"));
        //myTimer.AutoReset = true;
        //myTimer.Elapsed += new System.Timers.ElapsedEventHandler(myTimer_Elapsed);
        //myTimer.Enabled = true;
    }

    public void myTimer_Elapsed(object source, System.Timers.ElapsedEventArgs e)
    {
        // use your mailer code 
        //int intCount = clsPhongTro.Auto_UpTin();
        //try
        //{
        //    //Write Log
        //    string strPathLog = OsPortal.oStringHelper.fncGetAppSettings("PATH_LOG_AUTO_UPTIN");
        //    string strNewContent = DateTime.Now.ToString() + " => " + intCount + " tin được up lên";
        //    OsPortal.oFileHelper.WriteFileAppend(strNewContent, strPathLog);
        //}
        //catch (Exception ex) { }
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.Ignore("{resource}.axd/{*pathInfo}");
        routes.Ignore("robots.txt");
        routes.Ignore("sitemap");
        routes.Ignore("sitemap.gz");
        routes.Ignore("sitemap.xml");
        routes.Ignore("sitemap.xml.gz");
        routes.Ignore("google_sitemap.xml");
        routes.Ignore("google_sitemap.xml.gz");
        routes.Ignore("favicon.ico");
        routes.Ignore("images/{*pathInfo}");
        routes.Ignore("Scripts/{*pathInfo}");
        routes.Ignore("Styles/{*pathInfo}");
        //-----------------------------------------------------------------------------------------------------------------
        routes.MapPageRoute("client"
            , "{userControl}/{param1}/{param2}/{param3}/{param4}/{param5}"
            , "~/default.aspx"
            , true
            , new RouteValueDictionary { 
            { "userControl", "index" } 
            ,{ "param1", "" }
            ,{ "param2", "" }
            ,{ "param3", "" }
            ,{ "param4", "" }
            ,{ "param5", "" }
            });
    }
    
    void Application_End(object sender, EventArgs e) 
    {
        //  Code that runs on application shutdown

    }
        
    void Application_Error(object sender, EventArgs e) 
    { 
        // Code that runs when an unhandled error occurs

    }

    void Session_Start(object sender, EventArgs e) 
    {
        // Code that runs when a new session is started

    }

    void Session_End(object sender, EventArgs e) 
    {
        // Code that runs when a session ends. 
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer 
        // or SQLServer, the event is not raised.

    }

    //void Application_BeginRequest(object sender, EventArgs e)
    //{
    //    HttpApplication app = sender as HttpApplication;
    //    if (app != null)
    //    {
    //        string domain = "nghikhac.com";
    //        string host = app.Request.Url.Host.ToLower();
    //        string path = app.Request.Url.PathAndQuery;
    //        if (!String.Equals(host, domain))
    //        {
    //            Uri newURL = new Uri(app.Request.Url.Scheme +
    //            "://" + domain + path);
    //            app.Context.Response.RedirectPermanent(
    //            newURL.ToString(), endResponse: true);
    //        }
    //    }
    //}
       
</script>
